import 'package:flutter/material.dart';

import '../const.dart';

class InputField extends StatefulWidget {
  final Key fieldKey;
  final String labelText;
  final String helperText;
  final Map map;
  final String mapKey;
  final icon;
  final onTap;

  const InputField({Key key, this.fieldKey, this.labelText, this.helperText, this.map, this.mapKey, this.icon, this.onTap}) : super(key: key);



  @override
  _InputFieldState createState() => _InputFieldState();
}

class _InputFieldState extends State<InputField> {

  @override
  Widget build(BuildContext context) {
    return TextField(
      onChanged: (value) {
        widget.map[widget.mapKey] = value;
      },
      key: widget.fieldKey,
      obscureText: false,
      style: TextStyle(fontSize: 16, color: Const.blue),
      decoration: InputDecoration(
        labelText: widget.labelText,
        labelStyle: TextStyle(color: Const.black, fontSize: 18),
        focusedBorder: UnderlineInputBorder(
            borderSide: BorderSide(
              color: Const.blue,
          width: 1,
        )),
        enabledBorder: UnderlineInputBorder(
            borderSide: BorderSide(
          color: Const.blue,
          width: 1,
        )),
        suffixIcon: GestureDetector(
          onTap: widget.onTap,
          child: Icon(
            widget.icon,
            color: Const.blue,
          ),
        ),
      ),
    );
  }
}
